package common.datedemo;

import java.text.ParseException;
import java.util.Calendar;

/**
 * 获取当前时间是第几周，美国一周第一天是星期天
 *
 * Created by dong peng on 2017/11/21.
 */
public class WeekTest {

    public static void main(String[] args) throws ParseException {

//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
//        Date date = simpleDateFormat.parse("2017-09-04 17:44:18");
//        System.out.println(date);

        Calendar calendar = Calendar.getInstance();
//        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        int wk1 = calendar.get(Calendar.WEEK_OF_MONTH);
        System.out.println(wk1);
        calendar.set(2016,0,3);
        System.out.println(calendar.getTime());
        System.out.println(calendar.getTimeInMillis());
        int wk2 = calendar.get(Calendar.WEEK_OF_YEAR);
        System.out.println(wk2);
    }
}
